#!/bin/bash
source .env
source ./scripts/_functions.sh

function encode_password() {
  perl -e 'use URI::Escape; $encoded = uri_escape("'$1'"); print "$encoded\n";'
}

function upload_files() {
  bn="wordpress"
  password=$(encode_password $FTP_PASSWORD)
  wput -v --basename="$bn/" "$bn/$1" \
    "ftp://${FTP_USER}:${password}@${FTP_HOST}${FTP_REMOTEPATH}/"
}

upload_files "wp-content/themes/mysite/"
upload_files "wp-content/plugins/"
